package cn.jhc;


import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.apache.http.impl.bootstrap.HttpServer;
import org.apache.http.impl.bootstrap.ServerBootstrap;

public class SimperServer {
    public static void main(String[] args) throws IOException {
        HttpServer server = ServerBootstrap.bootstrap()
            .setListenerPort(5040)
            .setServerInfo("ServerTest/1.0")
            .addInterceptorFirst(new MyHttpRequestInterceptor())
            .registerHandler("/", new RootHandler())
            .registerHandler("/html/*", new RootHandler())
            .registerHandler("/submit.do", new SubmitHandler())
            .create();
        server.start();

       Runtime.getRuntime().addShutdownHook(new Thread(){
           @Override
           public void run() {
               server.shutdown(5, TimeUnit.SECONDS);
           }
       }); 
    }
}
